package com.qf.day06;

import com.qf.day08.Flyable;

import java.awt.datatransfer.FlavorListener;

/**
 * Dog类继承Animal类，在类名后面加关键字extends后面加上父类
 */
public class Dog extends Animal implements Comparable<Dog>, Flyable {
    private String vocal;  //狗叫

    /**
     * 在子类的构造方法中，需要调用父类的构造方法
     * 如果不明确写调用父类的哪个构造，那么编译器会默认添加调用父类的无参构造 super()
     */
    public Dog() {
        //不写也会有默认的父类无参构造
        super("小黄","牧羊犬","男",2);
        this.vocal="汪汪";
    }

    public Dog(String vocal) {
        //调用父类的无参构造
        super();
        this.vocal = vocal;
    }

    public Dog(String name, String type, String sex, int age, String vocal) {
        super(name, type, sex, age);
        this.vocal = vocal;
    }

    //看家
    public void lookHouse(){
        System.out.println(getName()+"在看家");
        int hungry = this.getHungry();
        this.setHungry(hungry+1);
    }
    public String getVocal() {
        return vocal;
    }

    public void setVocal(String vocal) {
        this.vocal = vocal;
    }

    /**
     * return "Dog{" +
     *                 "vocal='" + vocal + '\'' +
     *                 "} " + super.toString();
     * @return
     */
    @Override
    public String toString() {
        return "Dog{" +
                    "name"+getName()+
                    "type"+getType()+
                    "sex"+getSex()+
                    "age"+getAge()+
                    "hungr"+getHungry()+
                      ","+"vocal='" + vocal + '\'' +
                      "} ";
    }

    /**
     * 接口的方法需要再类中进行实现
     * 这个方法的目的，要比较两个dog对象的大小关系
     * 按照dog的年龄进行比较大小
     * @param o the object to be compared.
     * @return
     */
    @Override
    public int compareTo(Dog o) {
        //获取当前dog 的年龄
        int age = this.getAge();
        //获取比较对象的年龄
        int targetAge = o.getAge();
        return age-targetAge;
    }

    @Override
    public void fly() {
        System.out.println("dog在aoao 飞！！！！");
    }

    @Override
    public void fireable() {
        System.out.println("dog在喷火");
    }

    @Override
    public void swim() {
        System.out.println("小狗在游泳");
    }
}
